﻿' ----------------------------------------------------------------------------------
' Microsoft Developer & Platform Evangelism
' 
' Copyright (c) Microsoft Corporation. All rights reserved.
' 
' THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 
' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES 
' OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ----------------------------------------------------------------------------------
' The example companies, organizations, products, domain names,
' e-mail addresses, logos, people, places, and events depicted
' herein are fictitious.  No association with any real company,
' organization, product, domain name, email address, logo, person,
' places, or events is intended or should be inferred.
' ----------------------------------------------------------------------------------

Imports System.Data.Services.Common
Imports System.ComponentModel
Imports System

<DataServiceKey("PartitionKey", "RowKey")>
Public MustInherit Class TableServiceEntity
    Implements INotifyPropertyChanged
    Private _partitionKey As String
    Private _rowKey As String
    Private _timestamp As Date

    Public Sub New()
    End Sub

    Public Sub New(ByVal partitionKey As String, ByVal rowKey As String)
        Me._partitionKey = partitionKey
        Me._rowKey = rowKey
        Me._timestamp = Date.UtcNow
    End Sub

    Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged

    Public Overridable Property PartitionKey() As String
        Get
            Return Me._partitionKey
        End Get

        Set(ByVal value As String)
            Me._partitionKey = value
            Me.OnPropertyChanged("PartitionKey")
        End Set
    End Property

    Public Overridable Property RowKey() As String
        Get
            Return Me._rowKey
        End Get

        Set(ByVal value As String)
            Me._rowKey = value
            Me.OnPropertyChanged("RowKey")
        End Set
    End Property

    Public Property Timestamp() As Date
        Get
            Return Me._timestamp
        End Get

        Set(ByVal value As Date)
            Me._timestamp = value
            Me.OnPropertyChanged("Timestamp")
        End Set
    End Property

    Protected Overridable Sub OnPropertyChanged(ByVal changedProperty As String)
        RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(changedProperty))
    End Sub
End Class
